package com.ch.ms.data.domain.account;

import com.alibaba.fastjson.annotation.JSONField;
import com.ch.ms.data.domain.AbstractMaplePersistable;
import com.ch.ms.data.domain.character.ChmsCharacter;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.List;

@Entity
@Table(name = "chms_account", schema = "chms_new")
@DynamicInsert
@DynamicUpdate
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ChmsAccount extends AbstractMaplePersistable<Integer> {
    private static final long serialVersionUID = -8964995668683783324L;
    private String userName;
    private String password;
    private String salt;
    private boolean logged;


    @JSONField(serialize = false)
    @OneToMany(fetch = FetchType.LAZY)
    @JoinColumn(name = "account_id")
    private List<ChmsCharacter> characters;

}
